New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-range

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-range

Create ranges of notes

  • 0.69.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
decreased by-59.68%
Maintainers
1
Weekly downloads
 
Created
Source

tonal-range npm version

tonal

tonal-range is a collection of functions to create note ranges.

This is part of tonal music theory library.

You can install via npm: npm i --save tonal-range

API Reference

range(begin, end)Array

Create a numeric range. As parameters, it accepts numbers or note names. It can create ascending or descending ranges.

fromPitchSet(coll, midi)String

Given a collection of pitch classes and a midi number, return the note name from the collection or null if not in the collection.

This function can be partially applied.

noteRange(gen, start, end)Array

Create a note range using a function that convert from midi number to note names

Can be partially applied

chromatic(start, end)Array

Create a range of chromatic notes. The altered notes will use flats.

cycleOfFifths(the, the, the)Array

Create a range with a cycle of fifths

scaleRange(notes, start, end)Array

Create a scale range. Given a pitch set (a collection of pitch classes), and a start and end it returns a note range.

range(begin, end) ⇒ Array

Create a numeric range. As parameters, it accepts numbers or note names. It can create ascending or descending ranges.

Kind: global function
Returns: Array - an array of numbers or empty array if not valid parameters

ParamTypeDescription
beginPitch | String | Numberthe beginning note or number
endPitch | String | Numberthe end note or number

Example

import { range } from 'tonal-range'
range('C5', 'C4') // => [ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60 ]
range(10, 5) // => [ 10, 9, 8, 7, 6, 5 ]
// or use tonal
tonal.range('C2', 'C3')

fromPitchSet(coll, midi) ⇒ String

Given a collection of pitch classes and a midi number, return the note name from the collection or null if not in the collection.

This function can be partially applied.

Kind: global function
Returns: String - the note name or null if note in the pitch classes

ParamTypeDescription
collArraythe pitch classes collection
midiNumberthe midi number

Example

var fromPitchSet = require('note-ranges').fromPitchSet
fromPitchSet('C D E', 60) // => 'C4'
aMajor = fromPitchSet('A C# E')
[69, 70, 71, 72, 73].map(aMajor) // => [ 'A4', null, null, null, 'C#5' ]

noteRange(gen, start, end) ⇒ Array

Create a note range using a function that convert from midi number to note names

Can be partially applied

Kind: global function
Returns: Array - an array of note names

ParamTypeDescription
genfunctionthe note name generator. Its a function with signature (Number) => (String) that receives a note midi number and returns a note name
startString | Pitch | Integerthe first note (or midi number) of the range
endString | Pitch | Integerthe last note (or midi number) of the range

chromatic(start, end) ⇒ Array

Create a range of chromatic notes. The altered notes will use flats.

Kind: global function
Returns: Array - an array of note names

ParamTypeDescription
startString | Pitch | Integerthe first note (or midi number) of the range
endString | Pitch | Integerthe last note (or midi number) of the range

Example

tonal.chromatic('C2', 'E2') // => ['C2', 'Db2', 'D2', 'Eb2', 'E2']

cycleOfFifths(the, the, the) ⇒ Array

Create a range with a cycle of fifths

Kind: global function
Returns: Array - a range of cycle of fifths

ParamTypeDescription
theIntegerfirst step from tonic
theIntegerlast step from tonic (can be negative)
theString | Pitchtonic

Example

var range = require('tonal-ranges')
range.cycleOfFifths(0, 6, 'C') // => [ 'C', 'G', 'D', 'A', 'E', 'B', 'F#' ])

scaleRange(notes, start, end) ⇒ Array

Create a scale range. Given a pitch set (a collection of pitch classes), and a start and end it returns a note range.

Kind: global function
Returns: Array - the scale range, an empty array if not valid source or null if not valid start or end

ParamTypeDescription
notesString | Arraythe collection of pitch sets
startStringthe first note of the range
endStringthe last note of the range

Example

var range = require('tonal-ranges')
range.scale('C D E F G A B', 'C3', 'C2')
// => [ 'C3', 'B2', 'A2', 'G2', 'F2', 'E2', 'D2', 'C2' ]

Keywords

FAQs

Package last updated on 06 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc